/*************************************************************************
	> File Name: P1229.cpp
	> Author: yufangze
	> Mail: 2224590123@qq.com
	> Created Time: 2025-04-09 10:06:09
 ************************************************************************/

#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
    string a, b;
    cin >> a >> b;
    int cnt = 0;
    for (int i = 0; i < a.size() - 1; i++) {
        for (int j = 1; j < b.size(); j++) {
            if (a[i] == b[j] && a[i + 1] == b[j - 1]) {
                cnt += 1;
            }
        }
    }
    cout << (1 << cnt) << endl;
    return 0;
}
